package ar.edu.uba.fi.jmit.aspecter.parser.parsers;

import ar.edu.uba.fi.jmit.aspecter.core.Constants;
import ar.edu.uba.fi.jmit.aspecter.core.WeavingInstrumentor;
import ar.edu.uba.fi.jmit.aspecter.core.WeavingInstrumentorFactory;
import ar.edu.uba.fi.jmit.aspecter.parser.configurations.ConfigurationClass;
import ar.edu.uba.fi.jmit.aspecter.parser.exception.XMLParserRuntimeException;

public class ObjectCounterMonitorParse extends MonitorParse {

	@Override
	public WeavingInstrumentor closeMonitor(String enviromentSelected) throws ClassNotFoundException {
		WeavingInstrumentor instrumentor = null; 
		if (!this.applyParse(enviromentSelected)){
			return instrumentor;
		}
		
		ConfigurationClass conf = (ConfigurationClass)this.configurations.getConfiguration(Constants.CLASS);
		validate(conf);
		
		return WeavingInstrumentorFactory.getInstance().getObjectCounterInstrumentor(this.monitorName, conf.getClassName(), this.priority);
	}

	public void validate(ConfigurationClass confClass){
		if (confClass == null){
			throw new XMLParserRuntimeException("Tag Class is missing");
		}
	}
	
}
